home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / redo / redoCommit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  4.0 KB  |  173 lines

  1. /*
  2.  *   $RCSfile: redoCommit.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:58 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "latch.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "openlog.h"
  58. #include "trans.h"
  59. #include "logrecs.h"
  60. #include "logaction.h"
  61. #include "util_funcs.h"
  62. #include "log_intfuncs.h"
  63. #include "log_extfuncs.h"
  64. #include "recover_intfuncs.h"
  65. #include "recover_extfuncs.h"
  66. #include "redo_extfuncs.h"
  67. #include "bf_extfuncs.h"
  68. #include "thread_globals.h"
  69. #include "trans_extfuncs.h"
  70. #include "trans_globals.h"
  71. #include "distr.h"
  72. #include "distr_globals.h"
  73. #include "distr_extfuncs.h"
  74.  
  75.  
  76.  void
  77. redoCommit (
  78.  
  79.     register LOGRECORDHDR    *record,
  80.     register LSNOFFSET        unused 
  81. )
  82. {
  83.     TRANSREC                *transRec;
  84.  
  85.     TRACE(TR_LOG|TR_RECOVER, TR_LEVEL_1);
  86.  
  87.     if ((transRec = findTransRec(record->tid)) == NULL)    {
  88.         return;
  89.     }
  90.  
  91.     TRPRINT(TR_LOG|TR_RECOVER, TR_LEVEL_1, ("action %d", record->action));
  92.     /*
  93.      *    process the record
  94.      */
  95.     switch (record->action)    {
  96.  
  97.         case LOG_ACTION_DISTR_COORD_COMMIT:
  98.  
  99.             if (transRec->transState != T_COMMIT) {
  100.  
  101.                 /*
  102.                  *    mark the state of the transaction
  103.                  */
  104.                 transRec->transState = T_COMMIT;
  105.  
  106.                 /*
  107.                  *  initialize the number of acks received
  108.                  */
  109.                 transRec->numAcksRecd = 0;
  110.  
  111.                 /*
  112.                  *  make sure this trans is on list of distr trans
  113.                  */
  114.                 SM_ASSERT(LEVEL_3, 
  115.                           (findDistrTransRec(transRec->tid, &CoordDistrTransList) != NULL));
  116.             }
  117.  
  118.             break;
  119.  
  120.         case LOG_ACTION_DISTR_SERVER_COMMIT:
  121.  
  122.             /*
  123.              *    Remove all pages from the dirty page table which were
  124.              *    deallocated by this transaction.
  125.              */
  126.             removeDeallocedDirtyPages(transRec);
  127.  
  128.             /*
  129.               *  initialize the state to inactive
  130.               */
  131.             transRec->transState = T_INACTIVE;
  132.  
  133.             /*
  134.              *  initialize the list components
  135.              */
  136.             listRemove( &(transRec->activeTransList) );
  137.  
  138.             /*
  139.               *  check if this is a distributed transaction
  140.               */
  141.             if (LIST_MEMBER(&(transRec->distrTransList))) {
  142.  
  143.                 /*
  144.                  *  take it off the list of active distr transactions
  145.                  */
  146.                 listRemove( &(transRec->distrTransList) );
  147.  
  148.                 /*
  149.                  *  decrement the number of active distr transactions
  150.                  */
  151.                 numActiveServerDistrTrans--;
  152.             }
  153.  
  154.             /*
  155.               *  move the transaction to the free pool
  156.               */
  157.             poolMove( &TransRecPool, &(transRec->tidList) );
  158.  
  159.             break;
  160.  
  161.         case NULL:
  162.             
  163.             break;
  164.  
  165.         default:
  166.  
  167.             TRPRINT(TR_LEVEL_1, TR_RECOVER,
  168.                 ("redoCommit() : unknown action %d", record->action));
  169.             SM_ERROR(TYPE_FATAL, esmINTERNAL);
  170.             break;
  171.     }
  172. }
  173.